package com.yusp75.myexam.util

import androidx.databinding.InverseMethod
import com.yusp75.myexam.R


// 练习顺序
object ExerciseOrderConverter {
    @InverseMethod("getRadioId")
    @JvmStatic
    fun getExerciseOrder(id: Int): Int {
        return when (id) {
            R.id.radio_ordered -> 0
            R.id.radio_random -> 1
            else -> 0
        }
    }

    @JvmStatic
    fun getRadioId(mode: Int): Int {
        return when (mode) {
            0 -> R.id.radio_ordered
            1 -> R.id.radio_random
            else -> R.id.radio_ordered
        }
    }
}

// 练习题型
object QuestionTypeConverter {
    @InverseMethod("getRadioId")
    @JvmStatic
    fun getExerciseType(id: Int): Int {
        return when (id) {
            R.id.rdAllType -> 0
            R.id.rdChoose -> 1
            R.id.rdJudge -> 2
            else -> 0
        }
    }

    @JvmStatic
    fun getRadioId(mode: Int): Int {
        return when (mode) {
            0 -> R.id.rdAllType
            1 -> R.id.rdChoose
            2 -> R.id.rdJudge
            else -> R.id.rdAllType
        }
    }
}